import axios, { AxiosInstance, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios'

// axios 跨域请求携带 cookie
axios.defaults.withCredentials = true

/**
 * 发起一个请求
 * @param url
 * @param config
 */
export async function request(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse> {
    return axios(url, config).then(value => {
        return Promise.resolve(value as any);
        
    }).catch((error) => {
        return Promise.reject(error);
    })
}
